/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cinemasystem.app.modules.bookmovie_lucky.Impl;

import com.cinemasystem.model.CinemaRoom;
import com.cinemasystem.app.modules.bookmovie_lucky.CinemaRoomService;
import com.cinemasystem.services.crud.CinemaroomCrudService;
import java.util.List;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 *
 * @author given
 */
public class CinemaRoomServiceImpl implements CinemaRoomService{
    private ApplicationContext ctx;
    private CinemaroomCrudService cinemaroomCrudService;
    @Override
    public CinemaRoom getCinemaRoom(String cinemaName) {
        ctx = new ClassPathXmlApplicationContext("classpath:com/cinemasystem/app/conf/applicationContext-*.xml");
        cinemaroomCrudService = (CinemaroomCrudService) ctx.getBean("cinemaroomCrudService");
        List<CinemaRoom> cinemaRooms = cinemaroomCrudService.findAll();
        for(CinemaRoom cinemaRoom: cinemaRooms){
            if(cinemaName.equalsIgnoreCase(cinemaRoom.getCinemaName())){
                return cinemaRoom;
            }
        }
        return null;
    }
    
}
